package com.api.shopapi.service.impl;

import com.api.shopapi.entity.ElderlyDrugRecord;
import com.api.shopapi.mapper.ElderlyDrugRecordMapper;
import com.api.shopapi.service.ElderlyDrugRecordService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author maochuan
 */
@Service("ElderlyDrugRecordServiceImplOne")
public class ElderlyDrugRecordServiceImpl implements ElderlyDrugRecordService {
    @Autowired
    private ElderlyDrugRecordMapper elderlyDrugRecordMapper;


    @Override
    public int insert(ElderlyDrugRecord elderlyDrugRecord) {
        return elderlyDrugRecordMapper.insert(elderlyDrugRecord);
    }

    @Override
    public ElderlyDrugRecord getByElderlyDrugRecordCode(String elderlyDrugRecordCode) {
        return elderlyDrugRecordMapper.getByElderlyDrugRecordCode(elderlyDrugRecordCode);
    }

    @Override
    public PageInfo<ElderlyDrugRecord> getPageList(int pageIndex, int pageSize, String institutionCode, String elderlyName, String startTime, String endTime) {
        PageHelper.startPage(pageIndex, pageSize);
        List<ElderlyDrugRecord> elderlyDrugRecordList = elderlyDrugRecordMapper.getPageList(institutionCode,elderlyName,startTime,endTime);
        PageInfo<ElderlyDrugRecord> pageInfo = new PageInfo<>(elderlyDrugRecordList);
        return pageInfo;
    }
}
